<template>
  <div>
    <!-- flex垂直水平居中 -->
    <div class="box">
      <div class="child" />
    </div>
    <!-- 利用子绝父相 -->
    <div class="box1">
      <div class="child1" />
    </div>
  </div>
</template>

<script>
import { debounce } from '../utils/tools'
export default {
  data() {
    return {
      num: 100,
      numOne: 10,
      text: ''
    }
  },
  // watch: {
  //   text(newValue, oldValue) {
  //     var vm = this
  //     // console.log('newValue--', newValue, oldValue)
  //     debounce((vm.newValue, vm.oldValue) => {
  //       console.log('newValue--', newValue, oldValue)
  //     }, 3000)
  //   }
  // },
  created() {
    this.$watch('text', debounce((newValue, oldValue) => {
      console.log('newValue--', newValue, oldValue)
    }, 3000))
    this.fn()
  },
  methods: {
    handleOpen(key, keyPath) {
      console.log(key, keyPath)
    },
    handleClose(key, keyPath) {
      console.log(key, keyPath)
    },
    fn() {
      var a = 10
      console.log(a, this.numOne, 'a---')
      // bar() {
      //   var a = 20
      //   console.log('bar---', a)
      // }
    }
  }
}
</script>

<style scoped>
/* 第一种 */
  .box {
    width: 500px;
    height: 500px;
    background: skyblue;
    display: flex;
    align-items: center;
    justify-content: center
  }
  .child {
    width: 200px;
    height: 200px;
    background: deepskyblue;
  }
/* 第二种 */
  /* .box1 {
    width: 500px;
    height: 500px;
    background: skyblue;
    position: relative;
  }
  .child1 {
    width: 200px;
    height: 200px;
    background: deepskyblue;
    position: absolute;
    /* 方案1 */
    /* left: 0;
    right: 0;
    top: 0;
    bottom: 0;
    margin: auto */
    /* 方案2 */
    /*top: 50%;
    left: 50%;
    transform: translate(-50%, -50%)
  } */
  /* 第三种 */
  /* .box1 {
    width: 500px;
    height: 500px;
    background: skyblue;
    text-align: center;
  }
  .box1:after {
    content: '';
    display: inline-block;
    height: 100%;
    width: 0;
    vertical-align: middle;
    background: blue;
  }
  .child1 {
    width: 200px;
    height: 200px;
    background: deepskyblue;
    display: inline-block;
    vertical-align: middle;

  } */
</style>
